


# 哈希查找


def twoSum(self, nums: list[int], target: int) -> list[int]:
    # 初始化哈希表
    hash_map = {}
    # 遍历 nums 数组
    for i in range(len(nums)):
        # 计算差值
        diff = target - nums[i]
        # 如果在哈希表中找到了相应的差值，返回 [hash_map[diff], i]
        if diff in hash_map:
            return [hash_map[diff], i]
        # 将当前元素的值加入哈希表中
        hash_map[nums[i]] = i



